export const loginAppid = ''
export const serviceApp = ''
// 项目路由
export const PROJECT_NAME = ''
export const PROJECT_NAME_CN = ''

// 针对特殊场地需要加一层访问前缀 如：ydy/project-name
// 获取访问前缀 如：ydy (没有则返回false)
export const PREFIX = (() => {
    const regPrefix = new RegExp(`^(/(.*))/${PROJECT_NAME}`)
    const { pathname } = window.location
    if (regPrefix.test(pathname)) {
        return pathname.match(regPrefix)[2]
    }
    return false
})()

// 拼接通用前缀
export const ROOT_PATH = PREFIX ? `/${PREFIX}/api` : '/api'

// 获取带前缀的url
// 忽略：以http或https开头、以相对路径开头的url
export const checkUrl = url => {
    if (/^https?|^[^/]/.test(url)) {
        return url
    }
    return PREFIX ? `/${PREFIX}${url}` : url
}
